<template>
  <view v-if="visible" class="custom-modal-mask">
    <view class="custom-modal">
      <view class="modal-title">
        {{ title }}
      </view>
	  <slot></slot> <!-- 确保插槽存在 -->
      <view class="modal-content">
        {{ content }}
      </view>
      <view class="modal-buttons">
        <view class="modal-button cancel" @click="handleCancel">取消</view>
        <view class="modal-button confirm" @click="handleConfirm">仍要离开</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: "",
    },
    content: {
      type: String,
      default: "",
    },
  },
  methods: {
    handleCancel() {
      this.$emit("cancel");
    },
    handleConfirm() {
      this.$emit("confirm");
    },
  },
};
</script>

<style scoped>
.custom-modal-mask {
  position: fixed;
  top: -200px;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.custom-modal {
  width: 70%;
  background-color: #fff;
  border-radius: 8px;
  box-sizing: border-box;
}

.modal-title {
  color: #141414;
  font-family: "PingFang SC";
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  line-height: 22px; /* 183.333% */
  text-align: center;
  margin-bottom: 10px;
}

.modal-content {
  color: #4e5969;
  font-size: 10px;
  text-align: center;
  margin-bottom: 5px;
}

.modal-buttons {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #ebebeb;
}

.modal-button {
  flex: 1;
  padding: 10px;
  text-align: center;
  cursor: pointer;
}

.cancel {
  color: #333;
  margin-right: 10px;
  border-right: 1px solid #ebebeb;
}

.confirm {
  color: #2F318B;
}
</style>